package game.Menus;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Vector2f;

/**
 * A horizontal menu is a menu which stores all its items horizontal.
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class HorizontalMenu extends Menu{

	/**
	 * Creates a new horizontal menu.
	 * @param startIndex The start index of the menu.
	 * @param gap THe gap between items.
	 */
	public HorizontalMenu(int startIndex, int gap) {
		super(startIndex, gap);
	}
	
	/**
	 * Moves the cursor left in the menu. It returns to the rightmost item when the cursor is moved to far left.
	 */
	public void left(){
		this.menuIndex--;
		if(this.menuIndex == -1){
			this.menuIndex = this.items.size()-1;
		}
	}
	
	/**
	 * Moves the cursor right in the menu. It returns to leftmost item when the cursor is moved to far right.
	 */
	public void right(){
		this.menuIndex++;
		this.menuIndex = this.menuIndex % (this.items.size());
	}
	@Override
	/**
	 * Draws the current Menu at a given position.
	 */
	public void draw(Vector2f startPosition, Graphics graphic) {
		int index = 0;
		for(MenuItem item : items){
			item.print(graphic, startPosition.copy().add(new Vector2f(index*gap,0)),this.menuIndex == index);
			index++;
		}
		
	}

}
